import sys
import time

if __name__ == "__main__":

    for i in range(3):
        # 方法1
        # sys.stdout.write('\r' + str(i))
        # sys.stdout.flush()

        # 方法2
        # print('\r' + str(i), end='', flush=True)
        print('\r' + str(i), end='', flush=True)

        time.sleep(0.3)
